/**
 * KQI分析，表格操作JS
 *
 */

/**********************表格定义***********************/
//质差终端排行表格
var zczdphTable;
//质差APN排行表格
var zcapnphTable;
//质差小区表格
var zcxqTable;
//质差用户表格
var zcyhTable;
/**********************END OF 表格定义***********************/

/**
 * 初始化质差终端排行表格
 * @param type
 * 		表盘类型（sbsy:首包时延表盘；sydksy:首页打开时延表盘；dnscgl:DNS成功率表盘；spxzsl:视频下载速率表盘；imcgl:IM成功率表盘；）
 */
function initZczdphTable(type){
	var city_code=$("#city_code").val();
	//var beginDate=$("#beginDate").val();
	//var endDate=$("#endDate").val();

	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	$("#zczdphTable tbody tr").remove();
	if (zczdphTable == undefined || zczdphTable == "undefined" || zczdphTable == null) {
	} else {
		zczdphTable.destroy();
	}
	zczdphTable = $('#zczdphTable')
			.DataTable(
					{
						"aoColumnDefs" : [ {
							sDefaultContent : '',
							aTargets : [ '_all' ]
						} ],
						"bPaginate" : false, // 翻页功能
						"bLengthChange" : false, // 改变每页显示数据数量
						"bFilter" : false, // 过滤功能
						"bSort" : false, // 排序功能
						"bInfo" : false,// 页脚信息
						"bAutoWidth" : true,// 自动宽度
						// "sPaginationType": "full_numbers",//显示分页的样式
						// 还有simple_numbers等
						"sScrollX" : "100%",
						"sScrollXInner" : "110%",
						"bScrollCollapse" : true,
						"oLanguage" : {
							"sLengthMenu" : "每页显示 _MENU_条",
							"sZeroRecords" : "没有找到符合条件的数据",
							"sProcessing" : "&nbsp;&nbsp;&nbsp;&nbsp;查询中，请稍等...",
							"sInfo" : "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
							"sInfoEmpty" : "没有记录",
							"sInfoFiltered" : "(从 _MAX_ 条记录中过滤)",
							"sSearch" : "搜索：",
							"oPaginate" : {
								"sFirst" : "首页",
								"sPrevious" : "前一页",
								"sNext" : "后一页",
								"sLast" : "尾页"
							}
						},
						"bProcessing" : true,
						"bServerSide" : true,
						"sAjaxSource" : "../../businessSense/kQIEvaluation/getZczdphTable",
						"fnServerData" : function(sSource, aoData, fnCallback) {
							$.ajax({
										"type" : "post",
										"contentType" : "application/x-www-form-urlencoded",
										"url" : sSource,
										"dataType" : "json",
										"data" : {
											"aoData" : JSON.stringify(aoData),
											"type" : type,
											"city_code" : city_code,
											"beginDate" : beginDate,
											"endDate" : endDate,
											"timeSize" : timeSize
										}, // 以json格式传递
										"success" : function(resp) {
											fnCallback(resp.allData);
										}
									});
						},
						columns : [
									{
										data : "report_date"
									},
									{
										data : "terminal_brand"
									},
									{
										data : "terminal_model",
										render : function(value,typeInfo,row){
											var report_date = row.report_date == undefined ? "" : row.report_date;
											var terminal_brand = row.terminal_brand == undefined ? "" : row.terminal_brand;
											var terminal_model = row.terminal_model == undefined ? "" : row.terminal_model;
											return "<a href='#' style=\"text-decoration: underline;\" onclick=\"forwordZczdphTable('"
											+ report_date + "','"
											+ terminal_brand +"','"
											+ terminal_model
											+ "')\"  >" + value + "</a>";
										}
									},
									{
										data : "user_num"
									},
									{
										data : "http_ratio"
									},
									{
										data : "frist_pack_time_delay"
									},
									{
										data : "frist_page_time_delay"
									},
									{
										data : "dns_ratio"
									},
									{
										data : "video_speed"
									},
									{
										data : "im_ratio"
									}]
			});
}

function forwordZczdphTable(report_date,terminal_brand,terminal_model) {
	var jspType = "kqi_evalution_zczdphTable"
	var timeSize = $('input:radio[name="timeSize"]:checked').val();
	var url = "";
	var title = "";
	//type sbsy sydksy dnscgl spxzsl imcgl
	if(type == 'dnscgl'){//DNS成功率
		url = "/businessAnalysis/dns/index?";
		title = "DNS指标";
	}else{
		url = "/businessAnalysis/hcq/index?";
		title = "HTTP过程指标"
	}
	url += "report_date=" + report_date +"&terminal_brand="+terminal_brand + "&terminal_model="+terminal_model 
	+"&jspType="+jspType+ "&timeSize=" + timeSize + "&type=" + type 
	linkTab(title, url)
}

function forwordZczdph(){
	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	var beginDate=$("#beginDate").val();
	var endDate=$("#endDate").val();
	var jspType = "kqi_evalution_zczdphTable_more";
	var city_code = $("#city_code").val();
	
	var url = "/businessAnalysis/terminalPerformance/index?jspType="+jspType+"&cityCode="+city_code
	+"&timeSize="+timeSize+"&beginDate="+beginDate+"&endDate="+endDate;
	var title = "终端性能";
	
	linkTab(title, url)

}

/**
 * 初始化质差APN排行表格
 * @param type
 * 		表盘类型（sbsy:首包时延表盘；sydksy:首页打开时延表盘；dnscgl:DNS成功率表盘；spxzsl:视频下载速率表盘；imcgl:IM成功率表盘；）
 */
function initZcapnphTable(type){
	var city_code=$("#city_code").val();
	//var beginDate=$("#beginDate").val();
	//var endDate=$("#endDate").val();

	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	$("#zcapnphTable tbody tr").remove();
	if (zcapnphTable == undefined || zcapnphTable == "undefined" || zcapnphTable == null) {
	} else {
		zcapnphTable.destroy();
	}
	zcapnphTable = $('#zcapnphTable')
			.DataTable(
					{
						"aoColumnDefs" : [ {
							sDefaultContent : '',
							aTargets : [ '_all' ]
						} ],
						"bPaginate" : false, // 翻页功能
						"bLengthChange" : false, // 改变每页显示数据数量
						"bFilter" : false, // 过滤功能
						"bSort" : false, // 排序功能
						"bInfo" : false,// 页脚信息
						"bAutoWidth" : true,// 自动宽度
						// "sPaginationType": "full_numbers",//显示分页的样式
						// 还有simple_numbers等
						"sScrollX" : "100%",
						"sScrollXInner" : "110%",
						"bScrollCollapse" : true,
						"oLanguage" : {
							"sLengthMenu" : "每页显示 _MENU_条",
							"sZeroRecords" : "没有找到符合条件的数据",
							"sProcessing" : "&nbsp;&nbsp;&nbsp;&nbsp;查询中，请稍等...",
							"sInfo" : "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
							"sInfoEmpty" : "没有记录",
							"sInfoFiltered" : "(从 _MAX_ 条记录中过滤)",
							"sSearch" : "搜索：",
							"oPaginate" : {
								"sFirst" : "首页",
								"sPrevious" : "前一页",
								"sNext" : "后一页",
								"sLast" : "尾页"
							}
						},
						"bProcessing" : true,
						"bServerSide" : true,
						"sAjaxSource" : "../../businessSense/kQIEvaluation/getZcapnphTable",
						"fnServerData" : function(sSource, aoData, fnCallback) {
							$.ajax({
										"type" : "post",
										"contentType" : "application/x-www-form-urlencoded",
										"url" : sSource,
										"dataType" : "json",
										"data" : {
											"aoData" : JSON.stringify(aoData),
											"type" : type,
											"city_code" : city_code,
											"beginDate" : beginDate,
											"endDate" : endDate,
											"timeSize" : timeSize
										}, // 以json格式传递
										"success" : function(resp) {
											fnCallback(resp.allData);
										}
									});
						},
						columns : [
									{
										data : "report_date"
									},
									{
										data : "apn",
										render : function(value,typeInfo,row){
											var report_date = row.report_date == undefined ? "" : row.report_date;
											var apn = row.apn == undefined ? "" : row.apn;
											return "<a href='#' style=\"text-decoration: underline;\" onclick=\"forwordzcapnphTable('"
											+ report_date + "','"
											+ apn 
											+ "')\"  >" + value + "</a>";
										}
									},
									{
										data : "user_num"
									},
									{
										data : "request_num"
									},
									{
										data : "http_ratio"
									},
									{
										data : "frist_pack_time_delay"
									},
									{
										data : "frist_page_time_delay"
									},
									{
										data : "dns_ratio"
									},
									{
										data : "video_speed"
									},
									{
										data : "im_ratio"
									}]
			});
}

function forwordzcapnphTable(report_date,apn) {
	var jspType = "kqi_evalution_zcapnphTable"
	var timeSize = $('input:radio[name="timeSize"]:checked').val();
	var url = "";
	var title = "";
	//type sbsy sydksy dnscgl spxzsl imcgl
	if(type == 'dnscgl'){//DNS成功率
		url = "/businessAnalysis/dns/index?";
		title = "DNS指标";
	}else{
		url = "/businessAnalysis/hcq/index?";
		title = "HTTP过程指标"
	}
	url += "report_date="+report_date +"&apn="+apn  
	+"&jspType="+jspType+ "&timeSize=" + timeSize + "&type=" + type 
	linkTab(title, url)
}

function forwordZcapnph(){
	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	var beginDate=$("#beginDate").val();
	var endDate=$("#endDate").val();
	var jspType = "kqi_evalution_zcapnph_more";
	var city_code = $("#city_code").val();
	
	var url = "/businessAnalysis/apnPerformance/index?jspType="+jspType+"&cityCode="+city_code
	+"&timeSize="+timeSize+"&beginDate="+beginDate+"&endDate="+endDate;
	var title = "APN性能";
	
	linkTab(title, url)
}

/**
 * 初始化质差小区表格
 * @param type
 * 		表盘类型（sbsy:首包时延表盘；sydksy:首页打开时延表盘；dnscgl:DNS成功率表盘；spxzsl:视频下载速率表盘；imcgl:IM成功率表盘；）
 */
function initZcxqTable(type){
	var city_code=$("#city_code").val();
	//var beginDate=$("#beginDate").val();
	//var endDate=$("#endDate").val();

	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	$("#zcxqTable tbody tr").remove();
	if (zcxqTable == undefined || zcxqTable == "undefined" || zcxqTable == null) {
	} else {
		zcxqTable.destroy();
	}
	zcxqTable = $('#zcxqTable')
			.DataTable(
					{
						"aoColumnDefs" : [ {
							sDefaultContent : '',
							aTargets : [ '_all' ]
						} ],
						"bPaginate" : false, // 翻页功能
						"bLengthChange" : false, // 改变每页显示数据数量
						"bFilter" : false, // 过滤功能
						"bSort" : false, // 排序功能
						"bInfo" : false,// 页脚信息
						"bAutoWidth" : true,// 自动宽度
						// "sPaginationType": "full_numbers",//显示分页的样式
						// 还有simple_numbers等
						"sScrollX" : "100%",
						"sScrollXInner" : "110%",
						"bScrollCollapse" : true,
						"oLanguage" : {
							"sLengthMenu" : "每页显示 _MENU_条",
							"sZeroRecords" : "没有找到符合条件的数据",
							"sProcessing" : "&nbsp;&nbsp;&nbsp;&nbsp;查询中，请稍等...",
							"sInfo" : "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
							"sInfoEmpty" : "没有记录",
							"sInfoFiltered" : "(从 _MAX_ 条记录中过滤)",
							"sSearch" : "搜索：",
							"oPaginate" : {
								"sFirst" : "首页",
								"sPrevious" : "前一页",
								"sNext" : "后一页",
								"sLast" : "尾页"
							}
						},
						"bProcessing" : true,
						"bServerSide" : true,
						"sAjaxSource" : "../../businessSense/kQIEvaluation/getZcxqTable",
						"fnServerData" : function(sSource, aoData, fnCallback) {
							$.ajax({
										"type" : "post",
										"contentType" : "application/x-www-form-urlencoded",
										"url" : sSource,
										"dataType" : "json",
										"data" : {
											"aoData" : JSON.stringify(aoData),
											"type" : type,
											"city_code" : city_code,
											"beginDate" : beginDate,
											"endDate" : endDate,
											"timeSize" : timeSize
										}, // 以json格式传递
										"success" : function(resp) {
											fnCallback(resp.allData);
										}
									});
						},
						columns : [
									{
										data : "report_date"
									},
									{
										data : "city_code",
										render : function(value,typeInfo,row){
											var report_date = row.report_date == undefined ? "" : row.report_date;
											var city_code = row.city_code == undefined ? "" : row.city_code;
											return "<a href='#' style=\"text-decoration: underline;\" onclick=\"forwordZcxqTable('"
											+ report_date + "','"
											+ city_code 
											+ "')\"  >" + value + "</a>";
										}
									},
									{
										data : "enodeb_id"
									},
									{
										data : "enodeb_name"
									},
									{
										data : "cell_id"
									},
									{
										data : "http_ratio"
									},
									{
										data : "frist_pack_time_delay"
									},
									{
										data : "frist_page_time_delay"
									},
									{
										data : "dns_ratio"
									},
									{
										data : "video_speed"
									},
									{
										data : "im_ratio"
									}]
			});
}

function forwordZcxqTable(report_date,city_code) {
	var jspType = "kqi_evalution_zcxqTable"
	var timeSize = $('input:radio[name="timeSize"]:checked').val();
	var url = "";
	var title = "";
	//type sbsy sydksy dnscgl spxzsl imcgl
	if(type == 'dnscgl'){//DNS成功率
		url = "/businessAnalysis/dns/index?";
		title = "DNS指标";
	}else{
		url = "/businessAnalysis/hcq/index?";
		title = "HTTP过程指标"
	}
	url += "report_date="+report_date +"&city_code="+city_code  
	+"&jspType="+jspType+ "&timeSize=" + timeSize + "&type=" + type 
	linkTab(title, url)
}

function forwordZcxq(){
	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	var beginDate=$("#beginDate").val();
	var endDate=$("#endDate").val();
	var jspType = "kqi_evalution_zcxq_more";
	var city_code = $("#city_code").val();
	
	var url = "/businessAnalysis/netelement/index?jspType="+jspType+"&city_code="+city_code
	+"&timeSize="+timeSize+"&beginDate="+beginDate+"&endDate="+endDate;
	var title = "网元性能分析";
	
	linkTab(title, url)
}
/**
 * 初始化质差用户表格
 * @param type
 * 		表盘类型（sbsy:首包时延表盘；sydksy:首页打开时延表盘；dnscgl:DNS成功率表盘；spxzsl:视频下载速率表盘；imcgl:IM成功率表盘；）
 */
function initZcyhTable(type){
	var city_code=$("#city_code").val();
	//var beginDate=$("#beginDate").val();
	//var endDate=$("#endDate").val();

	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	$("#zcyhTable tbody tr").remove();
	if (zcyhTable == undefined || zcyhTable == "undefined" || zcyhTable == null) {
	} else {
		zcyhTable.destroy();
	}
	zcyhTable = $('#zcyhTable')
			.DataTable(
					{
						"aoColumnDefs" : [ {
							sDefaultContent : '',
							aTargets : [ '_all' ]
						} ],
						"bPaginate" : false, // 翻页功能
						"bLengthChange" : false, // 改变每页显示数据数量
						"bFilter" : false, // 过滤功能
						"bSort" : false, // 排序功能
						"bInfo" : false,// 页脚信息
						"bAutoWidth" : true,// 自动宽度
						// "sPaginationType": "full_numbers",//显示分页的样式
						// 还有simple_numbers等
						"sScrollX" : "100%",
						"sScrollXInner" : "110%",
						"bScrollCollapse" : true,
						"oLanguage" : {
							"sLengthMenu" : "每页显示 _MENU_条",
							"sZeroRecords" : "没有找到符合条件的数据",
							"sProcessing" : "&nbsp;&nbsp;&nbsp;&nbsp;查询中，请稍等...",
							"sInfo" : "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
							"sInfoEmpty" : "没有记录",
							"sInfoFiltered" : "(从 _MAX_ 条记录中过滤)",
							"sSearch" : "搜索：",
							"oPaginate" : {
								"sFirst" : "首页",
								"sPrevious" : "前一页",
								"sNext" : "后一页",
								"sLast" : "尾页"
							}
						},
						"bProcessing" : true,
						"bServerSide" : true,
						"sAjaxSource" : "../../businessSense/kQIEvaluation/getZcyhTable",
						"fnServerData" : function(sSource, aoData, fnCallback) {
							$.ajax({
										"type" : "post",
										"contentType" : "application/x-www-form-urlencoded",
										"url" : sSource,
										"dataType" : "json",
										"data" : {
											"aoData" : JSON.stringify(aoData),
											"type" : type,
											"city_code" : city_code,
											"beginDate" : beginDate,
											"endDate" : endDate,
											"timeSize" : timeSize
										}, // 以json格式传递
										"success" : function(resp) {
											fnCallback(resp.allData);
										}
									});
						},
						columns : [
									{
										data : "report_date"
									},
									{
										data : "msisdn",
										render : function(value,typeInfo,row){
											var report_date = row.report_date == undefined ? "" : row.report_date;
											var msisdn = row.msisdn == undefined ? "" : row.msisdn;
											return "<a href='#' style=\"text-decoration: underline;\" onclick=\"forwordZcyhTable('"
											+ report_date + "','"
											+ msisdn 
											+ "')\"  >" + value + "</a>";
										}
									},
									{
										data : "imsi"
									},
									{
										data : "city_code"
									},
									{
										data : "traffic_sum"
									},
									{
										data : "http_ratio"
									},
									{
										data : "frist_pack_time_delay"
									},
									{
										data : "frist_page_time_delay"
									},
									{
										data : "dns_ratio"
									},
									{
										data : "video_speed"
									},
									{
										data : "im_ratio"
									}]
			});
}

function forwordZcyhTable(report_date,msisdn) {
	var jspType = "kqi_evalution_zcyhTable"
	var timeSize = $('input:radio[name="timeSize"]:checked').val();
	var url = "";
	var title = "";
	//type sbsy sydksy dnscgl spxzsl imcgl
	if(type == 'dnscgl'){//DNS成功率
		url = "/businessAnalysis/dns/index?";
		title = "DNS指标";
	}else{
		url = "/businessAnalysis/hcq/index?";
		title = "HTTP过程指标"
	}
	url += "report_date="+report_date +"&msisdn="+msisdn  
	+"&jspType="+jspType+ "&timeSize=" + timeSize + "&type=" + type 
	linkTab(title, url)
}

function forwordZcyh(){
	var timeSize=$('input:radio[name="timeSize"]:checked').val();
	var beginDate=$("#beginDate").val();
	var endDate=$("#endDate").val();
	var jspType = "kqi_evalution_zcyh_more";
	var city_code = $("#city_code").val();
	
	var url = "/businessAnalysis/userPerformance/index?jspType="+jspType+"&city_code="+city_code
	+"&timeSize="+timeSize+"&beginDate="+beginDate+"&endDate="+endDate;
	var title = "用户性能分析";
	
	linkTab(title, url)
}